<?php
ob_start();
session_start();
include "checksession.php";
include_once "../connect.php";

$alt_Id = $_GET["alt_Id"];

if (!empty($alt_Id)) {
    // ดึงข้อมูล  เงื่อนไขคือ cn_number = $cn_number
    $sql = "SELECT * ,altcomservice.* FROM `altcomservice` LEFT JOIN depart ON altcomservice.de_id = depart.de_id                                                                                
                                         LEFT JOIN employee ON altcomservice.emp_id = employee.emp_id   
                                         LEFT JOIN userlog  ON altcomservice.id_member = userlog.id_member
                                         LEFT JOIN comname ON altcomservice.cn_id = comname.cn_id
                                         WHERE altcomservice.alt_Id = '$alt_Id'
                                            ";
    $rs = mysql_query($sql);

    if ($rs) {

        $r = mysql_fetch_array($rs);
        $altDate = $r[alt_Date];
        $altTime = $r[alt_Time];
        $txtDatet = date('d-m-Y', strtotime($altDate));
        $txtTime = date('H:i', strtotime($altTime));
    } else {

        echo mysql_error();
    }
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Adinop Co., Ltd. was founded as an ingredients importer and local manufacturers’ distributor in 1986. We also function as an exporter of finished products</title>
        <link rel="stylesheet" href="../css/style.css"/>
    </head>
    <body>
        <div align="center">
            <form  
                method="Post"
                action="serviceComUpdateSave.php"
                name ="frmMain" id="frmMain" OnSubmit="return CheckValidate();" />
            <table><br />
                <thead>
                    <caption class="headerTable">แจ้งซ่อมคอมพิวเตอร์ </caption>
                </thead>
                <tr align="top">
                    <td>รหัสพนักงาน</td>
                    <td><input  id="txtEmpid" name="txtEmpid" type="text" value="<?= $r[emp_id] ?>" readonly/></td> 
                    <td width="50px"></td>
                    <td>ผู้แจ้ง</td>
                    <td><input id="txtNameEng" name="txtNameEng" type="text" value="<?= $r[emp_nameTh] ?>"readonly/></td>      
                </tr>
                <tr valign="top" >

                    <td>แผนกฝ่าย</td>
                    <td><input id="txtDepartment"  name="txtDepartment" type="text" value="<?= $r[departname] ?>" readonly/></td>  
                    <td width="50px"></td>
                    <td>รหัสเครื่อง</td>
                    <td><input id="txtNumber"  name="txtNumber" type="text" value="<?= $r[cn_number] ?>" readonly /></td>
                </tr>
                <tr valign="top" >
                    <td>อาการเสีย</td>
                    <td colspan="4"><textarea id="txtError"  rows="4" cols="50" name="txtError"/><? echo $r['alt_Error']; ?></textarea></td> 
                </tr>
                <tr valign="top" >
                </tr>
                <tr valign="top">
                    <td colspan="2">                      
                        <input name="chkProgram" type="checkbox" value="Program" id="chkProgram"  <?php if ($r[alt_Program] == 'Program') {
    echo "CHECKED";
}
?>/>โปรแกรม
                    </td> 
                </tr>
                <tr valign="top">                  
                    <td colspan="2">
                        <input name="chkDevice" type="checkbox"  value="Device" id="chkDevice" <?php if ($r[alt_Device] == 'Device') {
                                   echo "CHECKED";
                               }
?>/>  อุปกรณ์ต่อพ่วงและคอมพิวเตอร์                                                                                                                                                                                                                                                   
                    </td>
                </tr>
                <tr>
                    <td>
                        วันเวลาที่แจ้ง <input type="text" name="txtDate" value="<?= $txtDatet ?>" readonly>
                    </td>
                    <td>
                        เวลาที่แจ้ง <input type="text" name="txtTime" value="<?= $txtTime ?>" readonly>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" align="center"><input type="submit" name="Submit" value="Save"  /></td>
                </tr>     
                <input type="hidden" name="alt_Id" value="<?= $r[alt_Id] ?>"/>
                <input type="hidden" name="de_id" value="<?= $r[de_id] ?>"/>
                <input type="hidden" name="cn_id" value="<?= $r[cn_id] ?>"/>
                </form>

            </table>
        </div>
    </body>
</html>
